define([
  './defaultValue-0a909f67',
  './PrimitivePipeline-5640850a',
  './createTaskProcessorWorker',
  './Transforms-a05e5e6e',
  './Matrix3-315394f6',
  './Check-666ab1a0',
  './Math-2dbd6b93',
  './Matrix2-13178034',
  './RuntimeError-06c93819',
  './combine-ca22a614',
  './ComponentDatatype-f7b11d02',
  './WebGLConstants-a8cc3e8c',
  './GeometryAttribute-334718f8',
  './GeometryAttributes-f06a2792',
  './GeometryPipeline-8fb0db69',
  './AttributeCompression-b646d393',
  './EncodedCartesian3-81f70735',
  './IndexDatatype-a55ceaa1',
  './IntersectionTests-27d49265',
  './Plane-900aa728',
  './WebMercatorProjection-13a90d41'
], function (
  defaultValue,
  PrimitivePipeline,
  createTaskProcessorWorker,
  Transforms,
  Matrix3,
  Check,
  Math,
  Matrix2,
  RuntimeError,
  combine,
  ComponentDatatype,
  WebGLConstants,
  GeometryAttribute,
  GeometryAttributes,
  GeometryPipeline,
  AttributeCompression,
  EncodedCartesian3,
  IndexDatatype,
  IntersectionTests,
  Plane,
  WebMercatorProjection
) {
  'use strict'

  /* global require */

  const moduleCache = {}

  function getModule(moduleName) {
    let module = moduleCache[moduleName]
    if (!defaultValue.defined(module)) {
      if (typeof exports === 'object') {
        // Use CommonJS-style require.
        moduleCache[module] = module = require(`Workers/${moduleName}`)
      } else {
        // Use AMD-style require.
        // in web workers, require is synchronous
        require([`Workers/${moduleName}`], function (f) {
          module = f
          moduleCache[module] = f
        })
      }
    }
    return module
  }

  function createGeometry(parameters, transferableObjects) {
    const subTasks = parameters.subTasks
    const length = subTasks.length
    const resultsOrPromises = new Array(length)

    for (let i = 0; i < length; i++) {
      const task = subTasks[i]
      const geometry = task.geometry
      const moduleName = task.moduleName

      if (defaultValue.defined(moduleName)) {
        const createFunction = getModule(moduleName)
        resultsOrPromises[i] = createFunction(geometry, task.offset)
      } else {
        //Already created geometry
        resultsOrPromises[i] = geometry
      }
    }

    return Promise.all(resultsOrPromises).then(function (results) {
      return PrimitivePipeline.PrimitivePipeline.packCreateGeometryResults(results, transferableObjects)
    })
  }
  var createGeometry$1 = createTaskProcessorWorker(createGeometry)

  return createGeometry$1
})
